package com.hhp.cloud.shop.product.controller;

import java.util.Arrays;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.hhp.cloud.shop.product.entity.CommentReplayEntity;
import com.hhp.cloud.shop.product.service.CommentReplayService;
import com.hhp.cloud.shop.common.core.result.R;



/**
 * 商品评价回复关系
 *
 * @author hhp
 * @email 2437579794@qq.com
 * @date 2021-12-07 15:15:44
 */
@RestController
@RequestMapping("/api/v1/product/commentReplay")
public class CommentReplayController {
    @Autowired
    private CommentReplayService commentReplayService;

    /**
     * 信息
     */
    @ApiOperation(value = "商品评价回复关系详情")
    @ApiImplicitParam(name = "id", value = "商品评价回复关系id", required = true, paramType = "path", dataType = "Long")
    @GetMapping("/{id}")
    public R info(@PathVariable("id") Long id){
		return R.ok().setData(commentReplayService.getById(id));
    }

    /**
     * 保存
     */
    @ApiOperation(value = "新增商品评价回复关系")
    @PostMapping
    public R save(@RequestBody CommentReplayEntity commentReplay){
		commentReplayService.save(commentReplay);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改商品评价回复关系")
    @PutMapping("/{id}")
    public R update(@PathVariable("id") Long id, @RequestBody CommentReplayEntity commentReplay){
		commentReplayService.updateById(commentReplay);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除商品评价回复关系")
    @DeleteMapping
    public R delete(@RequestBody Long[] ids){
		commentReplayService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
